#ifndef _YEP_SCENETEST_SCENE_HANDLER_TEST_HPP
#define _YEP_SCENETEST_SCENE_HANDLER_TEST_HPP

#include "framework/Event.hpp"
#include "framework/Entity.hpp"
#include "core/Game.hpp"
#include "framework/Scene2d.hpp"

namespace yep
{

/**
 * @brief Tests the Scene handling
 **/
class SceneHandlerTest: public Entity
{
public:
    SceneHandlerTest( string name = "father", SceneHandlerTest *father = nullptr ):
        _name( name ), _father( father ) {}
    ~SceneHandlerTest() {}
    /**
    * @brief Happens when the object is added to a Scene.
    **/
    virtual void evCreate( Event &event ) {
        cout << _name << ": I born on the frame #" << event.getGame().getCurrentFrame() << endl;
        if(_father)
        {
            cout << _name << ": My father is too old, I have to kill him #" << event.getGame().getCurrentFrame() << endl;
            event.getScene().remove(*_father);
            _father = nullptr;
        }
    }

    /**
     * @brief Happens when the object is removed from a Scene.
     **/
    virtual void evDestroy( Event &event ) {
        cout << _name << ": I died on the frame #" << event.getGame().getCurrentFrame() << endl;
        delete this;
    }

    /**
     * @brief Happens if the object is added on the Scene::setup()
     **/
    virtual void evSceneBegin( Event &event ) {
        cout << _name << ": What a surprise, it is the Scene start. I will totally create a son here! #"
             << event.getGame().getCurrentFrame() << endl;
        event.getScene().add( *new SceneHandlerTest( "child", this ) );
    }

    /**
     * @brief Happens if the object is removed on the Scene::cleanup()
     **/
    virtual void evSceneEnd( Event &event ) {
        cout << _name << ": The scene is ending. It was good until it least. #"
             << event.getGame().getCurrentFrame() << endl;
    }

private:
    string _name;
    SceneHandlerTest *_father;
};

}

#endif // _YEP_SCENETEST_SCENE_HANDLER_TEST_HPP

